package com.power.project.model.vo;

import com.power.project.model.Ww_user;
import com.power.project.model.dto.UserDepartDTO;
import com.power.project.model.dto.UserTagDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * @Author mrzhao
 * @CreateDate 2024/6/26 10:17
 * @Desc TODO
 * @Version 1.0
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class UserDetailVO extends UserBaseVO {
    /**
     * 是否是某个部门的负责人
     */
    private Boolean isLeader;
    /**
     * 部门列表，包括是否为负责人
     */
    private List<UserDepartDTO> departList;
    /**
     * 标签列表
     */
    private List<UserTagDTO> tagList;

    public UserDetailVO(Ww_user user) {
        super(user);
    }

    public void setDepartList(List<UserDepartDTO> departList) {
        this.departList = departList;
        if (CollectionUtils.isNotEmpty(departList)
                && departList.stream().anyMatch(t -> Integer.valueOf(1).equals(t.getIsLeader()))) {
            this.isLeader = Boolean.TRUE;
        }
    }
}
